package com.fgr.service.Impl;

import com.fgr.beans.Help;
import com.fgr.mapper.HelpMapper;
import com.fgr.service.HelpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.Map;

@Service
public class HelpServiceImpl implements HelpService {
    @Autowired
    HelpMapper helpMapper;


    @Override
    public String AddHelp(Help help, HttpSession httpSession) {
        String userid = httpSession.getAttribute("userid").toString();
        help.sethUid(Integer.parseInt(userid));
        Integer integer = helpMapper.addHelpMap(help);
        if (integer>0){
            return "SUCCESS";
        }else {
            return "ERRO";
        }
    }

    @Override
    public Integer addHelp(Help help) {
        Integer flag = helpMapper.addHelpMap(help);
        return flag;
    }

    @Override
    public List<Help> findAllHelpStrayBg() {
        List<Help> allHelpStrayBg = helpMapper.findAllHelpStrayBg();
        return allHelpStrayBg;
    }

    @Override
    public String deleteHelpByhIdBg(Integer hId) {
        Integer integer = helpMapper.deleteHelpByhIdBg(hId);
        if (integer>0){
            return "SUCCESS";
        }else {
            return "ERRO";
        }
    }

    @Override
    public Help findHelpByHid(Integer hId) {
        Help help = helpMapper.findHelpByHid(hId);
        return help;
    }

    @Override
    public String addHelpBg(Help help) {
        Integer integer = helpMapper.addHelpBg(help);
        if (integer>0){
            return "SUCCESS";
        }else {
            return "ERRO";
        }
    }

    @Override
    public String updateHelpBg(Help help) {
        Integer integer = helpMapper.updateHelpBg(help);
        if (integer>0){
            return "SUCCESS";
        }else {
            return "ERRO";
        }
    }
}